//
//  DecryptAssurePassEvaluateListCell.m
//  MyProject
//
//  Created by 石小强 on 2018/5/11.
//  Copyright © 2018年 yanjiaming. All rights reserved.
//

#import "DecryptAssurePassEvaluateListCell.h"

@implementation DecryptAssurePassEvaluateListCell

- (void)awakeFromNib {
    [super awakeFromNib];

    self.headerIV.layer.cornerRadius = 19.5;
    self.headerIV.layer.masksToBounds = YES;
    self.headerIV.userInteractionEnabled = YES;
    UITapGestureRecognizer *tgr = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(iconClick)];
    [self.headerIV addGestureRecognizer:tgr];
}

- (IBAction)starViewValueChanged:(id)sender {
    self.starV.value = [self.model.star floatValue];
}

- (void)setModel:(CommentModel *)model {
    _model = model;
    
    [self.headerIV sd_setImageWithURL:ImageURLWithKey(model.publisherHeadImg) placeholderImage:PlaceholderImagePeople];
    self.nameL.text = model.publisher;
    self.contentL.text = model.content;
    NSArray *timeArr = [model.releaseTime componentsSeparatedByString:@" "];
    if (timeArr.count == 2) {
        self.timeL.text = [timeArr objectAtIndex:0];
    } else {
        self.timeL.text = model.releaseTime;
    }
    
    self.starV.value = [model.star floatValue];
                                                      
    if (model.comments && model.comments.count > 0) {
        CommentModel *comment = [model.comments objectAtIndex:0];
        self.replyL.text = [NSString stringWithFormat:@"同事回复：%@", comment.content];
    } else {
        self.replyL.text = @"";
    }
    
    if (model.targetPositon && model.targetPositon.length > 0) {
        self.serviceCategoryL.hidden = NO;
        self.serviceCategoryL.text = [NSString stringWithFormat:@"服务类型：%@", model.targetPositon];
    } else {
        self.serviceCategoryL.hidden = YES;
    }
}

- (void)iconClick {
    self.headerIconBlock(self.model.publisherId);
}

@end
